﻿@using CNKI.TPI.Web.Base
@using CNKI.TPI.Web.Search.Model
@if (ViewBag.SortField != null || ViewBag.listAbstract != null)
{
    <div class="order-box clearfix">
        @*排序*@
        @if (ViewBag.SortField != null)
        {
            <div class="fl">
                <label class="f-label" style="display: none">
                    <input type="checkbox">全选</label>
                <label class="f-label" style="display: none"><i class="iconfont iconfont-star-empty"></i>收藏</label>

                <span class='taxis'>排序：
                @foreach (DBUSFIELD item in ViewBag.SortField)
                {
                    if (ViewBag.SortFiledNow == item.RealFieldName)
                    {
                    <a href="javascript:void(0);" class='cur'  onclick="sortClick('@ViewBag.SortDescAsc','@item.RealFieldName')">@item.ShowFieldName
                        @if (@ViewBag.SortDescAsc == "desc")
                        {<i class="iconfontdesc"></i>}
                        else
                        {<i class="iconfontasc"></i>}
                    </a>
                    }
                    else
                    {
                    <a href="javascript:void(0);" onclick="sortClick('@ViewBag.SortDescAsc','@item.RealFieldName')">@item.ShowFieldName</a>
                    }

                }

                </span>
            </div>
        }
@*显示模式及分页汇总*@
        <div class="fr order-r">
            @if (ViewBag.listAbstract != null)
            {
                string strlist = "";
                string strabstract = "";
                <div class="lb">
                    @if (ViewBag.listAbstract == "list")
                    {
                        strlist = "class=cur";
                    }
                    else
                    {
                        strabstract = "class=cur";
                    }
                    <a href="javascript:void(0);" @strlist onclick="formatList('list')"><i class="iconfont iconfont-list"></i>列表</a>
                    <a href="javascript:void(0);" @strabstract  onclick="formatList('abct')"><i class="iconfont iconfont-abstract"></i>摘要</a>

                </div>
            }
            @{if (ViewBag.TotalPage != null && ViewBag.ResultCount != null && ViewBag.PageNow != null)
              {
                  if (@ViewBag.TotalPage == 0)
                  {
                <span>0 条结果 0 /0</span>
                  }
                  else
                  {
                <span>@ViewBag.ResultCount 条结果 @ViewBag.PageNow /@ViewBag.TotalPage</span>
                  }

                  if (ViewBag.TotalPage > 0 && ViewBag.PageNow != ViewBag.TotalPage)
                  {
                      int nextpage = ViewBag.PageNow + 1;
                <a href="javascript:void(0);" class="next-t" onclick="searchPageNew('@nextpage')" ></a>
                  }
                  else
                  {
                <a href="javascript:void(0);" class="next-t disable"></a>
                  }
              }
            }
        </div>
    </div>
}
@{if (ViewBag.listAbstract != null)
  {
      if (ViewBag.listAbstract == "list")
      {
          // 列表显示 
          if (ViewBag.SearchResult != null)
          {
    <table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey" id="table_list">
        <thead>
            <tr class="thead">
                <th class="tdnum">序号</th>
                @{ System.Data.DataRow columnInfo = null;
                   System.Data.DataRow[] columnInfoList = null;}
                @foreach (System.Data.DataColumn item in ViewBag.SearchResult.Columns)
                {
                    if (item.ColumnName != "__sys_from")
                    {
                        columnInfoList = ViewBag.DisplayColumnInfo.Select(string.Format("Name='{0}'", item.ColumnName));

                        if (columnInfoList.Length > 0)
                        {
                            columnInfo = columnInfoList[0]; //获取公共字段映射信息作为比较依据
                            if (@columnInfo["Name"].ToString() != "SYS_FLD_SYSID"
                             && @columnInfo["Name"].ToString() != "摘要" )
                            {
                    <th width="@columnInfo["Width"]%">@columnInfo["DispName"]</th>
                            }
                        }
                    }
                }
                <th>来源</th>
                @* <th>下载</th>*@
            </tr>
        </thead>
        <tbody>
            @{
                int sortno = ViewBag.PageSize * (ViewBag.PageNow - 1) + 1;
                foreach (System.Data.DataRow dr in ViewBag.SearchResult.Rows)
                {
                    int j = 0;
                    var str = dr["__sys_from"].ToString().Split('#');////数据库Id，code,名称，类型
                <tr>
                    <td style="word-break: normal" class="tc">
                        <input name="" type="checkbox" value="" style="display: none" />@sortno</td>
                    @foreach (System.Data.DataColumn column in ViewBag.SearchResult.Columns)
                    {

                        if (j == 0)//第一列加链接
                        {
                      
                        
                        <td><a target="_blank" href="@dr["SYS_FLD_URL"]">
                            @Html.Raw(ColumnAliasHelper.SubContent(ColumnAliasHelper.GetContent(dr, column.ColumnName),ConfigHelper.GetSearchResultCutLengh()))
                        </a></td>
                            }
                        else
                        {
                            if (column.ColumnName != "__sys_from")
                            {
                                columnInfoList = ViewBag.DisplayColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName));
                                if (columnInfoList.Length > 0)
                                {

                                    columnInfo = columnInfoList[0];//获取公共字段映射信息作为比较依据
                                    if (!columnInfo["Name"].ToString().StartsWith("SYS_FLD_SYSID") && columnInfo["Name"].ToString() != "摘要")
                                    {

                                        if (columnInfo["Name"].ToString() == "发表时间")
                                        { 
                        <td style="width: 100px; text-align: center">@Html.Raw(ColumnAliasHelper.GetContent(dr, column.ColumnName))</td>
                                        }
                                        else
                                        {
                        <td>@Html.Raw(ColumnAliasHelper.GetContent(dr, column.ColumnName))</td>
                                        }

                                    }
                                }


                            }
                        }

                        j++;
                    }
                    <td class="tc">@str[2]</td>
                    @*                    <td class="tc">
        @{
    int type = int.Parse(@str[3]);
            <a onclick="javascript:isDown(@int.Parse(str[0]), @dr["SYS_FLD_SYSID"].ToString(),
                @type,'@ResourceHelper.GetFileDownloadURLByRecoredIdAndType(int.Parse(str[0]), dr["SYS_FLD_SYSID"].ToString(), (MediaType)type)',
                 '@Html.Raw(Url.Action("IsShowDown", "File"))')"
           class='iconfont icon-xiajiantou2'></a>
        }
    </td>*@
                </tr>
                    sortno = sortno + 1;
                }
         
            }
        </tbody>
    </table>
          }
      }
      else
      {
          // 摘要显示 
          if (ViewBag.SearchResult != null)
          {
    <ul class="abstract" id="ul_abstract">
        @{int abstractno = ViewBag.PageSize * (ViewBag.PageNow - 1) + 1;
          foreach (System.Data.DataRow dr in ViewBag.SearchResult.Rows)
          {
              //var str = dr["__sys_from"].ToString().Split('#');////数据库Id，code,名称，类型
              
            <li>
                @{
              int m = 0;
              System.Data.DataRow columnInfo = null;
              System.Data.DataRow[] columnInfoList = null;
              foreach (System.Data.DataColumn column in ViewBag.SearchResult.Columns)
              {
                  columnInfoList = ViewBag.DisplayColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName));
                  if (columnInfoList != null && columnInfoList.Length > 0)
                  {
                      columnInfo = columnInfoList[0];

                      if (m == 0) //第一列加超链接
                {
                    <h2 class=''><a target="_blank" href="@dr["SYS_FLD_URL"]">@abstractno、 @Html.Raw(dr[column.ColumnName].ToString())</a></h2>
                                   
                      }
                      else if (m != 0 && !column.ColumnName.StartsWith("SYS_FLD")) //排除第一列标题列和系统字段
                      {
                          string colname = column.ColumnName;
                          if (!string.IsNullOrEmpty(columnInfo["DispName"].ToString()))
                          {
                              colname = columnInfo["DispName"].ToString();
                          }
                          if (!string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                          {
                    <p>@colname:  <span class="writer">@Html.Raw(dr[column.ColumnName].ToString())</span></p>
                          }

                      }

                      m++;
                  }
                }
                <div class="detail tr">
                        @if (dr.Table.Columns.Contains("访问量"))  //浏览量
                        {

                            columnInfoList = ViewBag.DisplayColumnInfo.Select(string.Format("Name='{0}'", "访问量"));
                            if (columnInfoList != null && columnInfoList.Length > 0)
                            {
                                columnInfo = columnInfoList[0];
                            <span>@columnInfo["DispName"].ToString(): @Html.Raw(dr["访问量"].ToString() == "" ? "0" : dr["访问量"].ToString())</span>
                            }
                        }
                        @if (dr.Table.Columns.Contains("下载量"))//下载量
                        {

                            columnInfoList = ViewBag.DisplayColumnInfo.Select(string.Format("Name='{0}'", "下载量"));
                            if (columnInfoList != null && columnInfoList.Length > 0)
                            {
                                columnInfo = columnInfoList[0];
                            <span>@columnInfo["DispName"].ToString(): @Html.Raw(dr["下载量"].ToString() == "" ? "0" : dr["下载量"].ToString())</span>
                            }
                        }


                </div>
                }
            </li>
                abstractno = abstractno + 1;

          }
        }
    </ul>
          }
      }
  }
}
@*//分页*@
<div class="pagenav pagenav-02">
    @if (ViewBag.TotalPage != null && ViewBag.PageList != null && ViewBag.PageNow != null && ViewBag.TotalPage > 0)
    {
@*上一页*@
        if (ViewBag.PageNow != 1)
        {
            int thispage = ViewBag.PageNow - 1;
        <a href="javascript:void(0);" class="page-prev" onclick="searchPageNew('@thispage')" >上一页</a>
        }
        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">上一页</a>
        }
@*循环初始化页码*@
        foreach (string numpage in ViewBag.PageList)
        {
            if (numpage != "0")
            {
                int m = int.Parse(numpage);
                if (m == ViewBag.PageNow)
                {
        <a href="javascript:void(0);" class="active" onclick="searchPageNew('@numpage')">@numpage</a>
                    
                }
                else
                {
        <a href="javascript:void(0);" onclick="searchPageNew('@numpage')">@numpage</a>
                }

            }
            else
            {
        <i class="iconfont icon-dian2"></i>
            }

        }
@*下一页*@
        if (ViewBag.TotalPage > 0 && ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
        <a href="javascript:void(0);" class="page-next" onclick="searchPageNew('@nextpage')" >下一页</a>
        }
        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">下一页</a>
        }
    }
    else
    {
        <label>暂无数据！</label>

    }
</div>




